import {Component} from "react";
import PropTypes from "prop-types";

class Person extends Component {

  // props是只读的
  // 对标签属性进行类型、必要性的限制
  static propTypes = {
    name: PropTypes.string.isRequired,
    age: PropTypes.number
  }
  // 指定标签属性的默认值
  static defaultProps = {
    age: 12
  }

  render() {
    const {name, age} = this.props
    return (
      <ul>
        <li>姓名：{name}</li>
        <li>年龄：{age}</li>
      </ul>
    )
  }

}

export default Person
